import util from '@/util/util'
import store from '@/store'
/**
 * 路由配置
 */
const tabsList: any[] = util.flatten(store.state.tabsList, 'children')
const Route: any = {
    routes: [],
    initRoutes: function () {
        const routes: any[] = Object.keys(this.routes).map((route: any) => {
            const keepAlive = route.split('/').length < 3
            const path = route !== '/' ? '/' + route : '/'
            const name = (tabsList.find(item => item.path === path && !item.icon) || {}).name

            return {
                name,
                path,
                component: this.routes[route],
                meta: { keepAlive }
            }
        })
        return routes
    }
}
export default Route
